cmake_minimum_required(VERSION 3.22)
project(Sofa.Component.ODESolver.Forward LANGUAGES CXX)

set(SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR "src/sofa/component/odesolver/forward")

set(HEADER_FILES
    ${SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR}/config.h.in
    ${SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR}/init.h
    ${SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR}/EulerSolver.h
    ${SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR}/EulerExplicitSolver.h
    ${SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR}/CentralDifferenceSolver.h
    ${SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR}/RungeKutta2Solver.h
    ${SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR}/RungeKutta4Solver.h
    ${SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR}/DampVelocitySolver.h
)

set(SOURCE_FILES
    ${SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR}/init.cpp
    ${SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR}/EulerExplicitSolver.cpp
    ${SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR}/CentralDifferenceSolver.cpp
    ${SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR}/RungeKutta2Solver.cpp
    ${SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR}/RungeKutta4Solver.cpp
    ${SOFACOMPONENTODESOLVERFORWARD_SOURCE_DIR}/DampVelocitySolver.cpp
)

sofa_find_package(Sofa.Simulation.Core REQUIRED)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Simulation.Core)

sofa_create_package_with_targets(
    PACKAGE_NAME ${PROJECT_NAME}
    PACKAGE_VERSION ${Sofa_VERSION}
    TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
    INCLUDE_SOURCE_DIR "src"
    INCLUDE_INSTALL_DIR "${PROJECT_NAME}"
)

cmake_dependent_option(SOFA_COMPONENT_ODESOLVER_FORWARD_BUILD_TESTS "Compile the automatic tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF)
if(SOFA_COMPONENT_ODESOLVER_FORWARD_BUILD_TESTS)
    add_subdirectory(tests)
endif()
